﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iPhoneTrackerWin.Data;

namespace iPhoneTrackerWin
{
    /// <summary>
    /// GPS Manager for the User Table
    /// </summary>
    public class UserManager : SQLiteDBManager<UserManager>
    {
        /// <summary>
        /// Contructor -> work on User Table
        /// </summary>
        public UserManager()
            : base("User")
        {
        }

        /// <summary>
        /// Liefert den Nutzer mit der angegebenen ID
        /// </summary>
        /// <param name="UserID"></param>
        /// <returns></returns>
        public User getUser(int UserID)
        {
            var user = from u in DefaultContext.User
                       where u.ID == UserID
                       select u;

            return user.FirstOrDefault();
        }

        /// <summary>
        /// Liefert den Nutzer mit dem angegebenen Namen, oder null falls dieser nicht existiert
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public User getUser(String username)
        {
            var user = from u in DefaultContext.User
                       where u.Username.Equals(username)
                       select u;

            return user.FirstOrDefault();
        }
    }
}
